<?php
class BaseController extends CController
{

    public function createUrl($route,$params=array(),$ampersand='&')
    {
        if($params['lang'] == Yii::app()->params['default_language'])
        	unset($params['lang']);
        return parent::createUrl($route,$params,$ampersand);
    }
    public function init()
    {
        parent::init();
        $lang = trim(strtolower(Yii::app()->request->getParam('lang')));
        if(!$lang || !isset(Yii::app()->params['langs'][$lang]))
            $lang = Yii::app()->params['default_language'];
        Yii::app()->language= $lang;
        BaseModel::setLang($lang);
    }
}